package com.woniuxy.creditsystem.mortgagemag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.creditsystem.common.bean.HouseFind;
import com.woniuxy.creditsystem.common.bean.HouseInfo;
import com.woniuxy.creditsystem.common.bean.VehicleFind;

import com.woniuxy.creditsystem.common.mapper.HouseMapper;
import com.woniuxy.creditsystem.mortgagemag.service.IHouseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;



@Transactional(readOnly = true)
@Service
public class HouseServiceImpl implements IHouseService {

    @Resource
    private HouseMapper houseMapper;

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int saveHouseInfo(HouseInfo houseInfo) {
        return houseMapper.saveHouseInfo(houseInfo);
    }

    @Override
    public HouseInfo getOneById(Long id) {
        return houseMapper.getOneById(id);
    }

    @Override
    public PageInfo<HouseInfo> findAllByParams(int pageNum, int pageSize, HouseFind houseFind) {
        return PageHelper.startPage(pageNum,pageSize).
                doSelectPageInfo(()->houseMapper.findAllByParams(houseFind));
    }

    @Override
    public int deleteHouse(Long id) {
        return houseMapper.deleteHouse(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateHouse(HouseInfo houseInfo) {
        return houseMapper.updateHouse(houseInfo);
    }


}
